import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'index',
    redirect: '/login'
  },
  {
    path: '/home',
    name: 'home',
    component: HomeView,
    redirect: '/home/about',
    children: [

      {
        path: 'user',
        name: 'user',
        component: () => import('../views/userinfo/UserinfoList.vue')
      },
      {
        path: 'category',
        name: 'category',
        component: () => import('../views/category/CategoryList.vue')
      }, {
        path: 'author',
        name: 'author',
        component: () => import('../views/author/AuthorList.vue')
      }, {
        path: 'publisher',
        name: 'publisher',
        component: () => import('../views/publisher/PublisherList.vue')
      }, {
        path: 'book',
        name: 'book',
        component: () => import('../views/book/BookList.vue')
      }, {
        path: 'about',
        name: 'about',
        component: () => import('../views/AboutView.vue')
      }
    ]
  }, {
    path: '/login',
    name: 'login',
    component: () => import('../views/LoginView')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
